HAL FDCAN IRQ Handler and Callbacks Functions Migration ¶
This section provides information about the HAL FDCAN IRQ_Handler and Callbacks functions migration.
Note
The interrupt handling and callback for FDCAN clock calibration has been significantly redesigned from HAL1 to HAL2:
Clock calibration callback:
In HAL1, clock calibration events were managed through a single callback,
HAL_FDCAN_ClockCalibrationCallback(), triggered by the main interrupt handler with flags indicating calibration state changes or watchdog events.- In HAL2, this callback is split into two distinct functions:
HAL_FDCAN_CCU_CalibrationCallback()provides detailed calibration levels upon state changes.HAL_FDCAN_CCU_CalibrationWatchdogCallback()handles watchdog expiration events indicating calibration failure.
IRQ Handler:
In HAL1, a single interrupt handler,
HAL_FDCAN_IRQHandler(), manages all FDCAN interrupts on two interrupt lines ( fdcan_intr0_it and fdcan_intr1_it) and calibration interrupt fdcan_cal_it.- In HAL2, interrupt handling is separated by interrupt lines:
HAL_FDCAN_IRQHandler()manages interrupts on two interrupt lines.HAL_FDCAN_CCU_IRQHandler()is dedicated to handling interrupts on the clock calibration unit interrupt line.
Refer to Use case: Clock calibration (interrupt)
HAL FDCAN callbacks functions ¶
|
HAL1 |
HAL2 |
|---|---|
HAL_FDCAN_ClockCalibrationCallback(&hfdcan, FDCAN_IT_CALIB_STATE_CHANGED)
HAL_FDCAN_ClockCalibrationCallback(&hfdcan, FDCAN_IT_CALIB_WATCHDOG_EVENT)
|
HAL_FDCAN_CCU_CalibrationCallback(&hfdcan, HAL_FDCAN_CCU_CAL_LEVEL_BASIC_CALIBRATED)
HAL_FDCAN_CCU_CalibrationWatchdogCallback(&hfdcan)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Removed: use instead
|
|
|
Removed: use instead
|
|
|
Removed: TTCAN not supported in HAL2 |
|
|
Removed: TTCAN not supported in HAL2 |
|
|
Removed: TTCAN not supported in HAL2 |
|
|
Removed: TTCAN not supported in HAL2 |
HAL FDCAN register callbacks functions ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL1, the function HAL_FDCAN_RegisterCallback is used to register CORDIC callbacks using a single function with a specific callback ID. |
In HAL2, separate functions are available to register each specific CORDIC callback, providing more granularity and control over the callback registration process. |
HAL_FDCAN_RegisterCallback(&fdcan_handle,
HAL_FDCAN_TX_FIFO_EMPTY_CB_ID,
USER_FDCAN_TxFifoEmptyCallback)
HAL_FDCAN_RegisterCallback(&fdcan_handle,
HAL_FDCAN_RX_BUFFER_NEW_MSG_CB_ID,
USER_FDCAN_RxBufferNewMessageCallback)
HAL_FDCAN_RegisterCallback(&fdcan_handle,
HAL_FDCAN_HIGH_PRIO_MESSAGE_CB_ID,
USER_FDCAN_HighPriorityMessageCallback)
HAL_FDCAN_RegisterCallback(&fdcan_handle,
HAL_FDCAN_TIMESTAMP_WRAPAROUND_CB_ID,
FDCAN_TimestampWraparoundCallback)
HAL_FDCAN_RegisterCallback(&fdcan_handle,
HAL_FDCAN_ERROR_CALLBACK_CB_ID,
USER_FDCAN_ErrorCallback)
HAL_FDCAN_RegisterCallback(&fdcan_handle,
HAL_FDCAN_TIMEOUT_OCCURRED_CB_ID,
USER_FDCAN_TimeoutOccurred_Callback)
HAL_FDCAN_RegisterCallback(&fdcan_handle,
HAL_FDCAN_MSPINIT_CB_ID,
FDCAN_MSPInitCallback)
HAL_FDCAN_RegisterCallback(&fdcan_handle,
HAL_FDCAN_MSPDEINIT_CB_ID,
FDCAN_MSPDeinitCallback)
|
HAL_FDCAN_RegisterTxFifoEmptyCallback(&fdcan_handle, USER_FDCAN_TxFifoEmptyCallback)
HAL_FDCAN_RegisterRxBufferNewMessageCallback(&fdcan_handle, USER_FDCAN_RxBufferNewMessageCallback)
HAL_FDCAN_RegisterHighPriorityMessageCallback(&fdcan_handle, USER_FDCAN_HighPriorityMessageCallback)
HAL_FDCAN_RegisterTimestampWraparoundCallback(&fdcan_handle, USER_FDCAN_TimestampWraparoundCallback)
HAL_FDCAN_RegisterErrorCallback(&fdcan_handle, USER_FDCAN_FDCAN_ErrorCallback)
Removed as HAL_FDCAN_TimeoutOccurredCallback is no longer supported.
Removed because the functions HAL_FDCAN_MspInit() and HAL_FDCAN_MspDeInit() are removed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Removed as
|
|
|
Removed: TTCAN not supported in HAL2 |
|
|
Removed: TTCAN not supported in HAL2 |
|
|
Removed: TTCAN not supported in HAL2 |
|
|
Removed: TTCAN not supported in HAL2 |
Related concepts: Individual callback registration APIs replace global register and unregister functions
Related concepts: Remove MspInit and MspDeInit callbacks
HAL FDCAN unregister callbacks. ¶
|
HAL1 |
HAL2 |
|---|---|
HAL_FDCAN_UnRegisterCallback(&fdcan_handle,
HAL_FDCAN_TX_FIFO_EMPTY_CB_ID)
HAL_FDCAN_UnRegisterCallback(&fdcan_handle,
HAL_FDCAN_RX_BUFFER_NEW_MSG_CB_ID)
HAL_FDCAN_UnRegisterCallback(&fdcan_handle,
HAL_FDCAN_HIGH_PRIO_MESSAGE_CB_ID)
HAL_FDCAN_UnRegisterCallback(&fdcan_handle,
HAL_FDCAN_TIMESTAMP_WRAPAROUND_CB_ID)
HAL_FDCAN_UnRegisterCallback(&fdcan_handle,
HAL_FDCAN_ERROR_CALLBACK_CB_ID)
HAL_FDCAN_UnRegisterCallback(&fdcan_handle,
HAL_FDCAN_TIMEOUT_OCCURRED_CB_ID)
HAL_FDCAN_UnRegisterCallback(&fdcan_handle,
HAL_FDCAN_MSPINIT_CB_ID)
HAL_FDCAN_UnRegisterCallback(&fdcan_handle,
HAL_FDCAN_MSPDEINIT_CB_ID)
|
HAL_FDCAN_RegisterTxFifoEmptyCallback(&fdcan_handle, HAL_FDCAN_TxFifoEmptyCallback)
HAL_FDCAN_RegisterRxBufferNewMessageCallback(&fdcan_handle, HAL_FDCAN_RxBufferNewMessageCallback)
HAL_FDCAN_RegisterHighPriorityMessageCallback(&fdcan_handle, HAL_FDCAN_HighPriorityMessageCallback)
HAL_FDCAN_RegisterTimestampWraparoundCallback(&fdcan_handle, HAL_FDCAN_TimestampWraparoundCallback)
HAL_FDCAN_RegisterErrorCallback(&fdcan_handle, HAL_FDCAN_ErrorCallback)
Removed as HAL_FDCAN_TimeoutOccurredCallback is no longer supported.
Removed because the functions HAL_FDCAN_MspInit() and HAL_FDCAN_MspDeInit() are removed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Removed as
|
|
|
Removed: TTCAN not supported in HAL2 |
|
|
Removed: TTCAN not supported in HAL2 |
|
|
Removed: TTCAN not supported in HAL2 |
|
|
Removed: TTCAN not supported in HAL2 |
Related concepts: Individual callback registration APIs replace global register and unregister functions
Related concepts: Remove MspInit and MspDeInit callbacks
HAL FDCAN callback pointers. ¶
In HAL2, HAL1 separate callback pointers for RX FIFO0, RX FIFO1, and TX Event FIFO are unified into
hal_fdcan_fifo_cb_t, and transmit buffer abort and complete callbacks are merged into
hal_fdcan_tx_buffer_cb_t, simplifying and standardizing the interface.
|
HAL1 |
HAL2 |
|---|---|
|
|
|
|
|
|
|
|
No specific pointer type for FIFO0 in HAL2; use
|
|
|
No specific pointer type for FIFO1 in HAL2; use
|
|
|
No specific pointer type for Tx Event FIFO in HAL2; use
|
|
|
No specific pointer type for Tx Buffer Abort in HAL2; use
|
|
|
No specific pointer type for Tx Buffer Complete in HAL2; use
|
|
|
Removed as
|
|
|
Removed: TTCAN not supported in HAL2 |
|
|
Removed: TTCAN not supported in HAL2 |
|
|
Removed: TTCAN not supported in HAL2 |
|
|
Removed: TTCAN not supported in HAL2 |
HAL FDCAN IRQ handler function. ¶
|
HAL1 |
HAL2 |
|---|---|
HAL_FDCAN_IRQHandler(FDCAN_HandleTypeDef *hfdcan)
|
/* for interrupt line0 and line1 */
HAL_FDCAN_IRQHandler(hal_fdcan_handle_t *hfdcan)
/* for fdcan calibration interrupts */
HAL_FDCAN_CCU_IRQHandler(hal_fdcan_handle_t *hfdcan)
|
Related concept: Introduce specialized IRQ handlers